// 定义记分牌
class ScorePanel {
    score = 0;
    level = 1;
    scoreEl: HTMLElement;
    levelEl: HTMLElement;
    // 最大等级
    maxLevel: number;
    // 设置一个变量表示多少分时可以升级
    upScore: number;
    constructor(maxLevel: number = 10,upScore: number = 10) {
        this.scoreEl = document.getElementById('score')!
        this.levelEl = document.getElementById('level')!
        this.maxLevel = maxLevel
        this.upScore = upScore
    }
    addScore() {
        this.scoreEl.innerHTML = ++this.score + '';
        // 判断分数是多少
        if(this.score % this.upScore === 0) {
            this.LevelUp()
        }
    }
    // 提升等级的方法
    LevelUp() {
        if (this.level < this.maxLevel ) {
            this.levelEl.innerHTML = ++this.level + '';
        }
    }
}

export default ScorePanel